package make

import (
	"github.com/spf13/cobra"
	"strings"
	"wskyygyso/api/pkg/console"
)

var CmdMakeApi = &cobra.Command{
	Use:   "api",
	Short: "create model,request,controller,factory,seeder",
	Args:  cobra.ExactArgs(1),
	Run:   runMakeApi,
}

func runMakeApi(cmd *cobra.Command, args []string) {
	array := strings.Split(args[0], "/")
	if len(array) != 2 {
		console.Exit("api name format: v1/user")
	}
	newArgs := []string{
		array[1],
	}
	runCreateModel(cmd, newArgs)
	runMakeRequest(cmd, newArgs)
	runMakeController(cmd, args)
	runMakeFactory(cmd, newArgs)
	runMakeSeeder(cmd, newArgs)
}
